# 添加中间件用于拿到token中的用户id
from flask import request, g
from common.utils.jwt_util import check_token


def get_userinfo():
    token = request.headers.get("Authorization")
    g.user_id = None
    if token:
        data = check_token(token)
        if data:
            g.user_id = data.get("user_id")
